(function() {

    window.onload = function() {
        game.init();
    }
	var game = window.game = {
	    width: 0,
	    height: 0,
	
	    asset: null,
	    stage: null,
	    ticker: null,
	    state: null,
	    score: 0,
	
	    bg: null,
	    ground: null,
	    bird: null,
	    holdbacks: null,
	    gameReadyScene: null,
	    gameOverScene: null,
	
	    init: function() {
	        this.asset = new game.Asset();
	        this.asset.on('complete', function(e) {
	            this.asset.off('complete');
	            this.initStage();
	        }.bind(this));
	        this.asset.load();
	    },
		initStage: function() {
			
			// var winWidth = window.innerWidth || document.documentElement.clientWidth;
			// var winHeight = window.innerHeight || document.documentElement.clientHeight;
		    this.width = window.innerWidth || document.documentElement.clientWidth;
		    this.height = window.innerHeight || document.documentElement.clientHeight;
		    this.scale = 0.5;
		
		    //舞台画布
		    var renderType = location.search.indexOf('dom') != -1 ? 'dom' : 'canvas';
		
		    //舞台
		    this.stage = new Hilo.Stage({
		        renderType: renderType,
		        width: this.width,
		        height: this.height,
		        scaleX: this.scale,
		        scaleY: this.scale
		    });
		    document.body.appendChild(this.stage.canvas);
		
		    //启动计时器
		    this.ticker = new Hilo.Ticker(60);
		    this.ticker.addTick(Hilo.Tween);
		    this.ticker.addTick(this.stage);
		    this.ticker.start(true);
		
		    //绑定交互事件
		    this.stage.enableDOMEvent(Hilo.event.POINTER_START, true);
		    this.stage.on(Hilo.event.POINTER_START, this.onUserInput.bind(this));
		
		},
	}
})


